package iwhr.nsbd;

import iwhr.nsbd.bean.InPut;
import iwhr.nsbd.bean.TimeRangeData;
import iwhr.nsbd.util.*;
import iwhr.nsbd.bean.plan;
import iwhr.nsbd.bean.pump;

import java.text.DecimalFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;

import static iwhr.nsbd.util.Time.getLocalMonthHours;
import static iwhr.nsbd.util.Time.pumpTimePrint;

public class run {
    public static Map rData(Map<String,Object> paramMap){
//        System.out.println(paramData.get("upz"));

        /**
         出省时间范围
         */

        List<TimeRange> timeRanges = new ArrayList<>();
        for (TimeRangeData paramData : (List<TimeRangeData>)paramMap.get("timeRanges")) {
            timeRanges.add(new TimeRange(LocalDateTime.of(paramData.getSyear(), paramData.getSmonth(), paramData.getSday(),
                    paramData.getShour(), paramData.getSmin()), LocalDateTime.of(paramData.getEyear(), paramData.getEmonth(),
                    paramData.getEday(), paramData.getEhour(), paramData.getEmin())));
        }

        Map<Integer, List<TimeRange>> monthStartTimes = new HashMap<>();

        for (TimeRange range : timeRanges) {
            LocalDateTime start = range.getStartDateTime();
            int month = start.getMonthValue();
            if (!monthStartTimes.containsKey(month)) {
                monthStartTimes.put(month, new ArrayList<>());
            }
            monthStartTimes.get(month).add(range);
        }
        /**
         抽江时间范围
         */
        List<TimeRange> timeRanges1 = new ArrayList<>();
        for (TimeRangeData paramData : (List<TimeRangeData>)paramMap.get("timeRanges1")) {
            timeRanges1.add(new TimeRange(LocalDateTime.of(paramData.getSyear(), paramData.getSmonth(), paramData.getSday(),
                    paramData.getShour(), paramData.getSmin()), LocalDateTime.of(paramData.getEyear(), paramData.getEmonth(),
                    paramData.getEday(), paramData.getEhour(), paramData.getEmin())));
        }

        Map<Integer, List<TimeRange>> monthStartTimes1 = new HashMap<>();
        for (TimeRange range : timeRanges1) {
            LocalDateTime start = range.getStartDateTime();
            int month = start.getMonthValue();
            if (!monthStartTimes1.containsKey(month)) {
                monthStartTimes1.put(month, new ArrayList<>());
            }
            monthStartTimes1.get(month).add(range);
        }

        /**
         * 获得当前日报水量
         * */
        //接收上月调水量
        Map<String, Double> lastMonthWaterMap = new HashMap<>();
        InPut lastMonthWater = (InPut)paramMap.get("lastMonthWater");
        lastMonthWaterMap.put("泗洪", lastMonthWater.getSh());
        lastMonthWaterMap.put("睢宁2", lastMonthWater.getSn2());
        lastMonthWaterMap.put("沙集", lastMonthWater.getSj());
        lastMonthWaterMap.put("邳州", lastMonthWater.getPz());
        lastMonthWaterMap.put("泗阳", lastMonthWater.getSy());
        lastMonthWaterMap.put("刘老涧2", lastMonthWater.getLlj2());
        lastMonthWaterMap.put("皂河2", lastMonthWater.getZh2());
        lastMonthWaterMap.put("洪泽", lastMonthWater.getHz());
        lastMonthWaterMap.put("金湖", lastMonthWater.getJh());
        lastMonthWaterMap.put("江都", lastMonthWater.getJd());
        lastMonthWaterMap.put("宝应", lastMonthWater.getBy());
        lastMonthWaterMap.put("淮安4", lastMonthWater.getHa4());
        lastMonthWaterMap.put("淮阴3", lastMonthWater.getHy3());

        //年比例计算
        plan p = new plan();
        double[] yearPlanWater = {13.13, 13.56, 15.12};//[调水出省：年入骆马湖：年抽江水量]
        ProportionCalc calc = new ProportionCalc();
        p.setPlanProportionMonth(calc.calcProportion((double[])paramMap.get("year")));
        //徐洪河段损失比例计算
        double[] pumpXhhWater = {103400, 106972, 110038};//邳州站、沙集+睢宁二、泗洪站年计划提取水量
        p.setXhhProportion(calc.calcProportion2((double[])paramMap.get("xhh")));
        //入江水道计算损失比例计算
        double[] pumpRJSDWater = {115300, 115033, 113744};//宝应站、金湖站、洪泽站年计划提取水量
        p.setRjsdProportion(calc.calcProportion2((double[])paramMap.get("rjsd")));

        //中运河段 损失比例计算
        double[] pumpZyLakeWater = {56760, 57825, 58741};//皂河二、刘老涧二、泗阳站
        p.setZyLakeProportion(calc.calcProportion2((double[])paramMap.get("zyh")));
        double[] pumpLyLakeWater = new double[3];//与入江水道共用比例
        //不牢河段 损失比例计算
        double[] pumpBlLakeWater2 = {5028, 5390, 5403};//蔺家坝、解台、刘山
        p.setBlLakeProportion1(calc.calcProportion2((double[])paramMap.get("blh")));

        //泵站参数初始化
        //徐洪河段
        pump pumpPZ = new pump("邳州站", 0, 0, 0, 100, 0);
        pump pumpSJ = new pump("沙集站", 0, 0, 0, 50, 0);
        pump pumpSN2 = new pump("睢宁二站", 0, 0, 0, 60, 0);
        pump pumpSH = new pump("泗洪站", 0, 0, 0, 120, 0);
        //入江水道段
        pump pumpHZ = new pump("洪泽站", 0, 0, 0, 150, 0);
        pump pumpJH = new pump("金湖站", 0, 0, 0, 150, 0);
        pump pumpBY = new pump("宝应站", 0, 0, 0, 100, 0);
        pump pumpJD = new pump("江都站", 0, 0, 0, 400, 0);
        //中运河段
        pump pumpZH2 = new pump("皂河二站", 0, 0, 0, 75, 0);
        pump pumpLLJ2 = new pump("刘老涧二站", 0, 0, 0, 80, 0);
        pump pumpSY = new pump("泗阳站", 0, 0, 0, 175, 0);
        //里运河段
        pump pumpHA4 = new pump("淮安四站", 0, 0, 0, 100, 0);
        pump pumpHY3 = new pump("淮阴三站", 0, 0, 0, 100, 0);
        //不牢河段
        pump pumpLJB = new pump("蔺家坝", 0, 0, 0, 75, 0);
        pump pumpXT = new pump("解台站", 0, 0, 0, 125, 0);
        pump pumpLS = new pump("刘山站", 0, 0, 0, 125, 0);
        //台儿庄
        pump pumpTEZ = new pump("台儿庄站", 0, 0, 0, 125, 0);

        //输入方案开始时间
        int nextMonth = lastMonthWater.getNextMonth();
        //输入省厅下达下月计划调水出省
        double planWaterToSD = lastMonthWater.getPlanWaterToSD();//3.097872340425532 2.175  //1.5 出现3（1） pz：60m³/s  //2.0 出现3(2) pz：100m³/s //

        //输入上月骆马湖多抽水量
        double lastMothWater = lastMonthWater.getLastMothWater();

        //TODO：新增骆马湖年储存可变数组

//        ArrayList<Integer> lLakeWater = new ArrayList<>();
////        lLakeWater.add(2);


        List<Time> xhLakeTimeRange = null;//徐洪河段运行时间范围List
        String xhLakeFinishTime = null;//徐洪河完成计划时间
        String xhLakeFinishTime1 = null;//提前完成计划时间
        String xhLakeFinishTime2 = null;//双线输水运行满时间计划时间
        List<Time> zyLakeTimeRange = null;//中运河段运行时间范围List
        List<Time> jdPumpTimeRange= null;//江都站运行时间范围List
        List<Time> rjsdTimeRange= null;//入江水道段运行时间范围List
        String rjsdFinishTime = null;//入江水道完成计划时间
        List<Time> lyLakeTimeRange = null;//里运河运行时间范围List
        DecimalFormat decimalFormat = new DecimalFormat("#.##");
        //需入骆马湖水量
        double planWaterLmhNeed = planWaterToSD * p.getPlanProportionMonth()[1];
        //计算去掉上月仍需入骆马湖水量
        planWaterToSD -= lastMothWater / p.getPlanProportionMonth()[1];
        double planWaterLMH = planWaterToSD * p.getPlanProportionMonth()[1] * 10000;
        //计算抽江水量
        double planWaterOutCJ = planWaterToSD * p.getPlanProportionMonth()[2] * 10000;

        //是否开启不牢河出省
        boolean blLakeCondition = lastMonthWater.isBlLakeCondition();
        //设置蔺家坝站流量、水量
        double ljbInitFlow = lastMonthWater.getLjbInitFlow();
        double ljbInitSumWater = lastMonthWater.getLjbInitSumWater();


        /**状态判断*/
        boolean cJCondition = lastMonthWater.iscJCondition();//洪泽湖状态：是否抽江
        boolean jdPumpCondition = lastMonthWater.isJdPumpCondition();//江都站状态
        boolean sjPumpCondition = lastMonthWater.isSjPumpCondition();//沙集站状态

        System.out.println("下月计划调水出省：" + decimalFormat.format(planWaterToSD) + "亿m³");
        System.out.println("需入骆马湖" + decimalFormat.format(planWaterLmhNeed)+ "亿m³");
        System.out.println("仍然入骆马湖水量：" + decimalFormat.format(planWaterLMH/10000) + "亿m³");
        System.out.println("抽江水量：" + decimalFormat.format(planWaterOutCJ/10000) + "亿m³");

        //设置邳州站流量 限制
        double[][] constriant = {
                {30, 100},
                {30, 100},
                {30, 100},
                {30, 100},
                {30, 100},
                {30, 100},
                {30, 100},
                {30, 100},
                {30, 100}
        };
        double pzInitFlow = lastMonthWater.getPzInitFlow();
//        pzInitFlow = Math.max(0,Math.min(pzInitFlow, 100)); 设置邳州站流量限制
        double sn2InitFlow = lastMonthWater.getSn2InitFlow();
        //设置宝应站流量
        double byInitFlow = lastMonthWater.getByInitFlow();
        //设置江都站流量
        double jdInitFlow = lastMonthWater.getJdInitFlow();
        boolean pumpJdDayChange = lastMonthWater.isPumpJdDayChange();//是否修改江都站天数
        double pumpJdDay = lastMonthWater.getPumpJdDay(); //江都站设置天数
        //设置皂河二站流量
        double zh2InitFlow = lastMonthWater.getZh2InitFlow();
        //设置台儿庄流量
        double tezInitFlow = lastMonthWater.getTezInitFlow();
        double ha4InitFlow = lastMonthWater.getHa4InitFlow();//设置淮安四站流量
        boolean pumpHa4DayChange = lastMonthWater.isPumpHa4DayChange();//设置淮安四站流量
        double pumpHa4Day = lastMonthWater.getPumpHa4Day(); //淮安四站设置天数

        double dayXhh = 0;
        double dayRjsd = 0;
        double dayZyh = 0;
        double dayLyh = 0;
        double dayJdPump = 0;
        int daysOfMonth = 0;//每个月最多开机几天
        GetDayOfMonth gd = new GetDayOfMonth();//获取当月天数构造器
        daysOfMonth = gd.getDaysOfMonth() - 5;//当月停机5天可以运行的天数

        double localMonthHours = 0;//当月至月底时间范围的小时

        double daysToHours = 0;
        double daysToHoursCj = 0;

        double[] dayToHours;
        double[] dayToHoursCj;
        double daysToHoursJudge = 0;//徐洪河判断是否大于最大天数
        double daysToHoursJudge1 = 0;//中运河判断是否大于最大天数
        double daysToHoursJudgeCj = 0;//入江水道判断是否大于最大天数
        double daysToHoursJudgeCj1 = 0;//里运河判断是否大于最大天数


        // 输出月的开始时间对应的TimeRange对象
        DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
        Time c = new Time();
        ChangeDateRange C = new ChangeDateRange();
        C = c.getChangeDateRange(monthStartTimes, timeRanges, nextMonth);
        Time c1 = new Time();
        ChangeDateRange C1 = new ChangeDateRange();
        C1 = c1.getChangeDateRange(monthStartTimes1, timeRanges1, nextMonth);

        //逐次计算9种工况
        boolean planXhh = true;//徐洪河判断变量
        boolean planZyh = false;//中运河判断变量 true为不用
        /**只计算徐洪河*/
        if (planZyh){
            //优先双线输水
            planXhh = false;

            pumpPZ.setFlow(pzInitFlow);
            pumpPZ.setDay(planWaterLMH / (pzInitFlow + zh2InitFlow) / 8.64);
            pumpPZ.setSumWater(pumpPZ.getDay() * pumpPZ.getFlow()*8.64);
            //睢宁二站流量、水量、天数计算
            pumpSN2.setFlow(sn2InitFlow);
            pumpSN2.setDay(pumpPZ.getDay());
            pumpSN2.setSumWater(pumpSN2.getFlow() * pumpSN2.getDay() * 8.64);
            if (sjPumpCondition) {
                //沙集站流量、水量、天数计算
                pumpSJ.setSumWater(pumpPZ.getSumWater() * p.getXhhProportion()[0] - pumpSN2.getSumWater());
                pumpSJ.setFlow(pumpSJ.getSumWater() / pumpSN2.getDay() / 8.64);
                pumpSJ.setDay(pumpSJ.getSumWater() / pumpSJ.getFlow() / 8.64);
            }else {
                pumpSJ.setSumWater(0);
                pumpSJ.setFlow(0);
                pumpSJ.setSumWater(0);
                pumpSN2.setFlow(pumpPZ.getFlow() * p.getXhhProportion()[0]);
                pumpSN2.setSumWater(pumpPZ.getSumWater() * p.getXhhProportion()[0]);
                pumpSN2.setDay(pumpSN2.getSumWater() / pumpSN2.getFlow() / 8.64);
            }
            //泗洪站流量、水量、天数计算
            pumpSH.setSumWater((pumpSN2.getSumWater()+pumpSJ.getSumWater()) * p.getXhhProportion()[1]);
            pumpSH.setDay(pumpSN2.getDay());
            pumpSH.setFlow(pumpSH.getSumWater() / pumpSH.getDay() / 8.64);

            //皂河二站流量、水量计算
            pumpZH2.setFlow(zh2InitFlow);
            pumpZH2.setSumWater(planWaterLMH - pumpPZ.getSumWater());
            pumpZH2.setDay(pumpZH2.getSumWater() / pumpZH2.getFlow() / 8.64);
            //刘老涧二站流量、水量、天数计算
            pumpLLJ2.setFlow(pumpZH2.getFlow() * p.getZyLakeProportion()[0]);
            pumpLLJ2.setSumWater(pumpZH2.getSumWater() * p.getZyLakeProportion()[0]);
            pumpLLJ2.setDay(pumpLLJ2.getSumWater() / pumpLLJ2.getFlow() / 8.64);
            //泗阳站流量、水量、天数计算
            pumpSY.setFlow(pumpLLJ2.getFlow() * p.getZyLakeProportion()[1]);
            pumpSY.setSumWater(pumpLLJ2.getSumWater() * p.getZyLakeProportion()[1]);
            pumpSY.setDay(pumpSY.getSumWater() / pumpSY.getFlow() / 8.64);
            dayXhh = pumpPZ.getDay();
            dayZyh = pumpZH2.getDay();
            daysToHoursJudge = dayXhh * 24;
            daysToHoursJudge1 = dayZyh * 24;
            daysToHours = dayXhh * 24;
            dayToHours = new double[]{daysToHours, 0, 0, 0};
            double[] dayToHours1 = new double[]{daysToHoursJudge1, 0, 0, 0};
            if (daysToHoursJudge <= C.getTotalHoursInMonth() && daysToHoursJudge1 <= C.getTotalHoursInMonth()) {
                //获取在本月时间段范围内，今天至本月底需要的小时
                localMonthHours = getLocalMonthHours(C, localMonthHours, nextMonth);

                pumpSH.setThisMonthWater(pumpSH.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("泗洪"));
                pumpSJ.setThisMonthWater(pumpSJ.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("沙集"));
                pumpSN2.setThisMonthWater(pumpSN2.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("睢宁2"));
                pumpPZ.setThisMonthWater(pumpPZ.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("邳州"));
                pumpSY.setThisMonthWater(pumpSY.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("泗阳"));
                pumpLLJ2.setThisMonthWater(pumpLLJ2.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("刘老涧2"));
                pumpZH2.setThisMonthWater(pumpZH2.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("皂河2"));


                System.out.println("——————————————2.徐洪河+中运河——————————————");
                System.out.println(pumpSH);
                System.out.println(pumpSN2);
                if (sjPumpCondition) {
                    System.out.println(pumpSJ);
                }
                System.out.println(pumpPZ);
                System.out.println("运行时间：");
                //输出泵站运行时间范围
                xhLakeTimeRange = pumpTimePrint(C, dayToHours);
                for (Time result : xhLakeTimeRange) {
                    System.out.print("开始时间: " + result.getStartTime().format(formatter1) + "，");
                    System.out.println("结束时间: " + result.getEndTime().format(formatter1));
                }
                System.out.println(pumpSY);
                System.out.println(pumpLLJ2);
                System.out.println(pumpZH2);
                //输出中运河运行时间范围
                System.out.println("运行时间：");
                zyLakeTimeRange = pumpTimePrint(C, dayToHours1);
                for (Time result : zyLakeTimeRange) {
                    System.out.print("开始时间: " + result.getStartTime().format(formatter1) + "，");
                    System.out.println("结束时间: " + result.getEndTime().format(formatter1));
                }
                xhLakeFinishTime1 = xhLakeTimeRange.get(xhLakeTimeRange.size() - 1).getEndTime().format(formatter1);
                System.out.println("至" + xhLakeFinishTime1 +"完成调水入骆马湖任务" + decimalFormat.format(planWaterLMH / 10000) +"亿m³任务");
            }
            else {
                System.out.println(daysToHoursJudge/24);
                System.out.println(daysToHoursJudge1/24);
                System.out.println("超限制");
            }
            pumpPZ.setFlow(pzInitFlow);//设置邳州站流量为最大流量
            //邳州站、皂河二站天数计算
            pumpPZ.setDay((double) C.getTotalHoursInMonth() / 24);
            //邳州站水量计算
            pumpPZ.setSumWater(pumpPZ.getDay() * pumpPZ.getFlow() * 8.64);
            //睢宁二站流量、水量、天数计算
            pumpSN2.setDay(pumpPZ.getDay());
            pumpSN2.setFlow(sn2InitFlow);
            pumpSN2.setSumWater(pumpSN2.getFlow() * pumpSN2.getDay() * 8.64);
            //沙集站流量、水量、天数计算
            if (sjPumpCondition) {
                //沙集站流量、水量、天数计算
                pumpSJ.setSumWater(pumpPZ.getSumWater() * p.getXhhProportion()[0] - pumpSN2.getSumWater());
                pumpSJ.setFlow(pumpSJ.getSumWater() / pumpSN2.getDay() / 8.64);
                pumpSJ.setDay(pumpSJ.getSumWater() / pumpSJ.getFlow() / 8.64);
            }
            else {
                pumpSJ.setSumWater(0);
                pumpSJ.setFlow(0);
                pumpSJ.setSumWater(0);
                pumpSN2.setFlow(pumpPZ.getFlow() * p.getXhhProportion()[0]);
                pumpSN2.setSumWater(pumpPZ.getSumWater() * p.getXhhProportion()[0]);
                pumpSN2.setDay(pumpSN2.getSumWater() / pumpSN2.getFlow() / 8.64);
            }

            //泗洪站流量、水量、天数计算
            pumpSH.setSumWater((pumpSN2.getSumWater()+pumpSJ.getSumWater()) * p.getXhhProportion()[1]);
            pumpSH.setDay(pumpSN2.getDay());
            pumpSH.setFlow(pumpSH.getSumWater() / pumpSH.getDay() / 8.64);

            //皂河二站流量、水量计算
            pumpZH2.setFlow(zh2InitFlow);
            pumpZH2.setDay(pumpPZ.getDay());
            pumpZH2.setSumWater(pumpZH2.getFlow() * pumpZH2.getDay() * 8.64);

            //刘老涧二站流量、水量、天数计算
            pumpLLJ2.setSumWater(pumpZH2.getSumWater() * p.getZyLakeProportion()[0]);
            pumpLLJ2.setDay(pumpPZ.getDay());
            pumpLLJ2.setFlow(pumpLLJ2.getSumWater() / pumpLLJ2.getDay() / 8.64);
            //泗阳站流量、水量、天数计算
            pumpSY.setSumWater(pumpLLJ2.getSumWater() * p.getZyLakeProportion()[1]);
            pumpSY.setDay(pumpPZ.getDay());
            pumpSY.setFlow(pumpSY.getSumWater() /pumpSY.getDay() / 8.64);
            dayXhh = pumpPZ.getDay();
            dayZyh = pumpZH2.getDay();
            daysToHoursJudge = dayXhh * 24;
            daysToHoursJudge1 = dayZyh * 24;
            daysToHours = dayXhh * 24;
            dayToHours = new double[]{daysToHours, 0, 0, 0};
            double[] dayToHours2 = new double[]{daysToHoursJudge1, 0, 0, 0};
            if (daysToHoursJudge <= C.getTotalHoursInMonth() && daysToHoursJudge1 <= C.getTotalHoursInMonth()) {
                //获取在本月时间段范围内，今天至本月底需要的小时
                localMonthHours = getLocalMonthHours(C, localMonthHours, nextMonth);

                pumpSH.setThisMonthWater(pumpSH.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("泗洪"));
                pumpSJ.setThisMonthWater(pumpSJ.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("沙集"));
                pumpSN2.setThisMonthWater(pumpSN2.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("睢宁2"));
                pumpPZ.setThisMonthWater(pumpPZ.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("邳州"));
                pumpSY.setThisMonthWater(pumpSY.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("泗阳"));
                pumpLLJ2.setThisMonthWater(pumpLLJ2.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("刘老涧2"));
                pumpZH2.setThisMonthWater(pumpZH2.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("皂河2"));


                System.out.println("——————————————2.徐洪河+中运河——————————————");
                System.out.println(pumpSH);
                System.out.println(pumpSN2);
                if (sjPumpCondition) {
                    System.out.println(pumpSJ);
                }
                System.out.println(pumpPZ);
                System.out.println("运行时间：");
                //输出泵站运行时间范围
                xhLakeTimeRange = pumpTimePrint(C, dayToHours);
                for (Time result : xhLakeTimeRange) {
                    System.out.print("开始时间: " + result.getStartTime().format(formatter1) + "，");
                    System.out.println("结束时间: " + result.getEndTime().format(formatter1));
                }
                System.out.println(pumpSY);
                System.out.println(pumpLLJ2);
                System.out.println(pumpZH2);
                //输出中运河运行时间范围
                System.out.println("运行时间：");
                zyLakeTimeRange = pumpTimePrint(C, dayToHours2);
                for (Time result : zyLakeTimeRange) {
                    System.out.print("开始时间: " + result.getStartTime().format(formatter1) + "，");
                    System.out.println("结束时间: " + result.getEndTime().format(formatter1));
                }
                xhLakeFinishTime2 = xhLakeTimeRange.get(xhLakeTimeRange.size() - 1).getEndTime().format(formatter1);
                System.out.println("至" + xhLakeFinishTime2 +"完成调水入骆马湖" + decimalFormat.format((pumpPZ.getSumWater() + pumpSN2.getSumWater())/10000)+"亿m³");
            }
        }
        else if (planXhh) {
            //优先徐洪河单线输水
            //邳州站水量、天数计算
            pumpPZ.setFlow(pzInitFlow);
            pumpPZ.setSumWater(planWaterLMH);
            pumpPZ.setDay(pumpPZ.getSumWater() / pumpPZ.getFlow() / 8.64);
            //睢宁二站流量、水量、天数计算
            pumpSN2.setFlow(sn2InitFlow);
            pumpSN2.setDay(pumpPZ.getDay());
            pumpSN2.setSumWater(pumpSN2.getFlow() * pumpSN2.getDay() * 8.64);
            if (sjPumpCondition) {
                //沙集站流量、水量、天数计算
                pumpSJ.setSumWater(pumpPZ.getSumWater() * p.getXhhProportion()[0] - pumpSN2.getSumWater());
                pumpSJ.setFlow(pumpSJ.getSumWater() / pumpSN2.getDay() / 8.64);
                pumpSJ.setDay(pumpSJ.getSumWater() / pumpSJ.getFlow() / 8.64);
            }else {
                pumpSJ.setSumWater(0);
                pumpSN2.setFlow(pumpPZ.getFlow() * p.getXhhProportion()[0]);
                pumpSN2.setSumWater(pumpPZ.getSumWater() * p.getXhhProportion()[0]);
                pumpSN2.setDay(pumpSN2.getSumWater() / pumpSN2.getFlow() / 8.64);
            }
            //泗洪站流量、水量、天数计算
            pumpSH.setSumWater((pumpSN2.getSumWater()+pumpSJ.getSumWater()) * p.getXhhProportion()[1]);
            pumpSH.setDay(pumpSN2.getDay());
            pumpSH.setFlow(pumpSH.getSumWater() / pumpSH.getDay() / 8.64);
            dayXhh = pumpPZ.getDay();
            daysToHoursJudge = pumpPZ.getDay() * 24;
            daysToHours = dayXhh * 24;

            dayToHours = new double[]{daysToHours, 0, 0, 0};

            if (daysToHoursJudge <= C.getTotalHoursInMonth()) {

                //获取在本月时间段范围内，今天至本月底需要的小时
                localMonthHours = getLocalMonthHours(C, localMonthHours, nextMonth);

                pumpSH.setThisMonthWater(pumpSH.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("泗洪"));
                pumpSJ.setThisMonthWater(pumpSJ.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("沙集"));
                pumpSN2.setThisMonthWater(pumpSN2.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("睢宁2"));
                pumpPZ.setThisMonthWater(pumpPZ.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("邳州"));

                System.out.println("——————————————1.徐洪河——————————————");
                System.out.println(pumpSH);
                System.out.println(pumpSN2);
                if (sjPumpCondition){
                    System.out.println(pumpSJ);
                }
                System.out.println(pumpPZ);
                System.out.println("运行时间：");
                //输出泵站运行时间范围
                xhLakeTimeRange = pumpTimePrint(C, dayToHours);
                for (Time result : xhLakeTimeRange) {
                    System.out.print("开始时间: " + result.getStartTime().format(formatter1) + "，");
                    System.out.println("结束时间: " + result.getEndTime().format(formatter1));
                }
                xhLakeFinishTime = xhLakeTimeRange.get(xhLakeTimeRange.size()-1).getEndTime().format(formatter1);
                System.out.println("至" + xhLakeFinishTime +"完成调水入骆马湖任务" + decimalFormat.format(planWaterLMH/100000 *10.0) +"亿m³任务");

            }
            else {

                pumpPZ.setFlow(pzInitFlow);
                pumpPZ.setSumWater(planWaterLMH);
                pumpPZ.setDay(pumpPZ.getSumWater() / pumpPZ.getFlow() / 8.64);
                //睢宁二站流量、水量、天数计算
                pumpSN2.setFlow(sn2InitFlow);
                pumpSN2.setDay(pumpPZ.getDay());
                pumpSN2.setSumWater(pumpSN2.getFlow() * pumpSN2.getDay() * 8.64);
                if (sjPumpCondition) {
                    //沙集站流量、水量、天数计算
                    pumpSJ.setSumWater(pumpPZ.getSumWater() * p.getXhhProportion()[0] - pumpSN2.getSumWater());
                    pumpSJ.setFlow(pumpSJ.getSumWater() / pumpSN2.getDay() / 8.64);
                    pumpSJ.setDay(pumpSJ.getSumWater() / pumpSJ.getFlow() / 8.64);
                }else {
                    pumpSJ.setSumWater(0);
                    pumpSJ.setFlow(0);
                    pumpSJ.setSumWater(0);
                    pumpSN2.setFlow(pumpPZ.getFlow() * p.getXhhProportion()[0]);
                    pumpSN2.setSumWater(pumpPZ.getSumWater() * p.getXhhProportion()[0]);
                    pumpSN2.setDay(pumpSN2.getSumWater() / pumpSN2.getFlow() / 8.64);
                }
                //泗洪站流量、水量、天数计算
                pumpSH.setSumWater((pumpSN2.getSumWater()+pumpSJ.getSumWater()) * p.getXhhProportion()[1]);
                pumpSH.setDay(pumpSN2.getDay());
                pumpSH.setFlow(pumpSH.getSumWater() / pumpSH.getDay() / 8.64);



                pumpPZ.setFlow(pzInitFlow);//设置邳州站流量为最大流量
                //邳州站、皂河二站天数计算
                pumpPZ.setDay((double) C.getTotalHoursInMonth() / 24);
                //邳州站水量计算
                pumpPZ.setSumWater(pumpPZ.getDay() * pumpPZ.getFlow() * 8.64);
                //睢宁二站流量、水量、天数计算
                pumpSN2.setDay(pumpPZ.getDay());
                pumpSN2.setFlow(sn2InitFlow);
                pumpSN2.setSumWater(pumpSN2.getFlow() * pumpSN2.getDay() * 8.64);
                //沙集站流量、水量、天数计算
                if (sjPumpCondition){
                    pumpSJ.setDay(pumpSN2.getDay());
                    pumpSJ.setFlow(pumpSJ.getFlow());
                    pumpSJ.setSumWater(pumpSJ.getFlow() * pumpSJ.getDay() * 8.64);
                }else{
                    pumpSJ.setSumWater(0);
                    pumpSJ.setFlow(0);
                    pumpSJ.setSumWater(0);
                    pumpSN2.setFlow(pumpPZ.getFlow() * p.getXhhProportion()[0]);
                    pumpSN2.setSumWater(pumpPZ.getSumWater() * p.getXhhProportion()[0]);
                    pumpSN2.setDay(pumpSN2.getSumWater() / pumpSN2.getFlow() / 8.64);
                }

                //泗洪站流量、水量、天数计算
                pumpSH.setDay(pumpSN2.getDay());
                pumpSH.setFlow(pumpSH.getFlow());
                pumpSH.setSumWater(pumpSH.getFlow() * pumpSH.getDay() * 8.64);

                //皂河二站流量、水量计算
                pumpZH2.setFlow(zh2InitFlow);
                pumpZH2.setSumWater(planWaterLMH - pumpPZ.getSumWater());
                pumpZH2.setDay(pumpZH2.getSumWater() / pumpZH2.getFlow() / 8.64);
                //刘老涧二站流量、水量、天数计算
                pumpLLJ2.setFlow(pumpZH2.getFlow() * p.getZyLakeProportion()[0]);
                pumpLLJ2.setSumWater(pumpZH2.getSumWater() * p.getZyLakeProportion()[0]);
                pumpLLJ2.setDay(pumpLLJ2.getSumWater() / pumpLLJ2.getFlow() / 8.64);
                //泗阳站流量、水量、天数计算
                pumpSY.setFlow(pumpLLJ2.getFlow() * p.getZyLakeProportion()[1]);
                pumpSY.setSumWater(pumpLLJ2.getSumWater() * p.getZyLakeProportion()[1]);
                pumpSY.setDay(pumpSY.getSumWater() / pumpSY.getFlow() / 8.64);
                dayXhh = pumpPZ.getDay();
                dayZyh = pumpZH2.getDay();
                daysToHoursJudge = dayXhh * 24;
                daysToHoursJudge1 = dayZyh * 24;
                daysToHours = dayXhh * 24;
                dayToHours = new double[]{daysToHours, 0, 0, 0};
                double[] dayToHours2 = new double[]{daysToHoursJudge1, 0, 0, 0};
                if (daysToHoursJudge <= C.getTotalHoursInMonth() && daysToHoursJudge1 <= C.getTotalHoursInMonth()) {
                    //获取在本月时间段范围内，今天至本月底需要的小时
                    localMonthHours = getLocalMonthHours(C, localMonthHours, nextMonth);

                    pumpSH.setThisMonthWater(pumpSH.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("泗洪"));
                    pumpSJ.setThisMonthWater(pumpSJ.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("沙集"));
                    pumpSN2.setThisMonthWater(pumpSN2.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("睢宁2"));
                    pumpPZ.setThisMonthWater(pumpPZ.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("邳州"));
                    pumpSY.setThisMonthWater(pumpSY.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("泗阳"));
                    pumpLLJ2.setThisMonthWater(pumpLLJ2.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("刘老涧2"));
                    pumpZH2.setThisMonthWater(pumpZH2.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("皂河2"));


                    System.out.println("——————————————2.徐洪河+中运河——————————————");
                    System.out.println(pumpSH);
                    System.out.println(pumpSN2);
                    if (sjPumpCondition) {
                        System.out.println(pumpSJ);
                    }
                    System.out.println(pumpPZ);
                    System.out.println("运行时间：");
                    //输出泵站运行时间范围
                    xhLakeTimeRange = pumpTimePrint(C, dayToHours);
                    for (Time result : xhLakeTimeRange) {
                        System.out.print("开始时间: " + result.getStartTime().format(formatter1) + "，");
                        System.out.println("结束时间: " + result.getEndTime().format(formatter1));
                    }
                    System.out.println(pumpSY);
                    System.out.println(pumpLLJ2);
                    System.out.println(pumpZH2);
                    //输出中运河运行时间范围
                    System.out.println("运行时间：");
                    zyLakeTimeRange = pumpTimePrint(C, dayToHours2);
                    for (Time result : zyLakeTimeRange) {
                        System.out.print("开始时间: " + result.getStartTime().format(formatter1) + "，");
                        System.out.println("结束时间: " + result.getEndTime().format(formatter1));
                    }
                    xhLakeFinishTime = xhLakeTimeRange.get(xhLakeTimeRange.size() - 1).getEndTime().format(formatter1);
                    System.out.println("至" + xhLakeFinishTime +"完成调水入骆马湖任务" +decimalFormat.format(planWaterLMH / 10000) +"亿m³任务");
                }
            }
        }

        //计算抽江
        //设置宝应站流量、水量、天数计算
        if (cJCondition) {
            pumpBY.setFlow(byInitFlow);
            pumpBY.setSumWater(planWaterOutCJ);
            pumpBY.setDay(pumpBY.getSumWater() / pumpBY.getFlow() / 8.64);
            //金湖站流量、水量、天数计算
            pumpJH.setFlow(pumpBY.getFlow() / p.getRjsdProportion()[0]);
            pumpJH.setSumWater(pumpBY.getSumWater() / p.getRjsdProportion()[0]);
            pumpJH.setDay(pumpJH.getSumWater() / pumpJH.getFlow() / 8.64);
            //洪泽站流量、水量、天数计算
            pumpHZ.setFlow(pumpJH.getFlow() / p.getRjsdProportion()[1]);
            pumpHZ.setSumWater(pumpJH.getSumWater() / p.getRjsdProportion()[1]);
            pumpHZ.setDay(pumpHZ.getSumWater() / pumpHZ.getFlow() / 8.64);
            dayRjsd = pumpHZ.getDay();
            daysToHoursJudgeCj = dayRjsd * 24;
            daysToHoursCj = dayRjsd * 24;
            dayToHoursCj = new double[]{daysToHoursCj, 0, 0, 0};
            if (daysToHoursJudgeCj <= C1.getTotalHoursInMonth()) {

                //获取在本月时间段范围内，今天至本月底需要的小时
                localMonthHours = getLocalMonthHours(C1, localMonthHours, nextMonth);

                pumpHZ.setThisMonthWater(pumpHZ.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("洪泽"));
                pumpJH.setThisMonthWater(pumpJH.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("金湖"));
                pumpBY.setThisMonthWater(pumpBY.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("宝应"));
                System.out.println("(1)抽江时，入江水道线不加江都站 满足");
                System.out.println(pumpHZ);
                System.out.println(pumpJH);
                System.out.println(pumpBY);
                System.out.println("运行时间：");
                //输出泵站运行时间范围
                rjsdTimeRange = pumpTimePrint(C1, dayToHoursCj);
                for (Time result : rjsdTimeRange) {
                    System.out.print("开始时间: " + result.getStartTime().format(formatter1) + "，");
                    System.out.println("结束时间: " + result.getEndTime().format(formatter1));
                }
                rjsdFinishTime = rjsdTimeRange.get(rjsdTimeRange.size() - 1).getEndTime().format(formatter1);
                System.out.println("至" + rjsdFinishTime +"完成抽江任务" + decimalFormat.format(planWaterOutCJ/10000) +"亿m³");

            }
            else {
                //如果是入江水道不足，加江都站
                /**金湖站正算*/
                //宝应站流量、水量、天数计算
                pumpBY.setFlow(byInitFlow);
                pumpBY.setSumWater(pumpBY.getFlow() * C1.getTotalHoursInMonth() / 24 * 8.64);
                pumpBY.setDay((double) C1.getTotalHoursInMonth() / 24);
//                System.out.println(Arrays.toString(p.getRjsdProportion1()));
                //江都站流量、水量、天数计算
                pumpJD.setDay(pumpBY.getDay());
                pumpJD.setSumWater(planWaterOutCJ - pumpBY.getSumWater());
                pumpJD.setFlow(pumpJD.getSumWater() / pumpJD.getDay() / 8.64);
                if (pumpJdDayChange){
                    pumpJD.setDay(pumpJdDay);
                    pumpJD.setFlow(pumpJD.getSumWater() / pumpJD.getDay() / 8.64);
                }
                if (pumpJD.getFlow() < 10.2){
                    pumpJD.setFlow(jdInitFlow);
                    pumpJD.setSumWater(planWaterOutCJ - pumpBY.getSumWater());
                    pumpJD.setDay(pumpJD.getSumWater() / pumpJD.getFlow() / 8.64);
                    if (pumpJD.getDay()*24 > C1.getTotalHoursInMonth()){
                        pumpJD.setFlow(pumpJH.getMaxFlow() / p.getRjsdProportion()[0] - pumpBY.getFlow());;
                        pumpJD.setDay(pumpBY.getDay());
                        pumpJD.setSumWater(pumpJD.getFlow() * pumpJD.getDay()*8.64);
                    }
                }else if (pumpJD.getFlow() > pumpJD.getMaxFlow()) {
                    pumpJD.setFlow(pumpJD.getMaxFlow());
                    pumpJD.setDay(pumpJD.getSumWater() / pumpJD.getFlow() / 8.64);
                }
                //金湖站流量、水量、天数计算
                pumpJH.setSumWater((pumpBY.getSumWater()+pumpJD.getSumWater()) * p.getRjsdProportion()[0]);
                pumpJH.setDay(pumpBY.getDay());
                pumpJH.setFlow(pumpJH.getSumWater() / pumpJH.getDay() / 8.64);

                //洪泽站流量、水量、天数计算
                pumpHZ.setSumWater(pumpJH.getSumWater() * p.getRjsdProportion()[1]);
                pumpHZ.setDay(pumpJH.getDay());
                pumpHZ.setFlow(pumpHZ.getSumWater() / pumpHZ.getDay() / 8.64);

                dayRjsd = pumpBY.getDay();
                dayJdPump = pumpJD.getDay();
                daysToHoursCj = dayRjsd * 24;
                daysToHoursJudgeCj = dayRjsd * 24;
                daysToHoursJudgeCj1 = dayJdPump * 24;
                dayToHoursCj = new double[]{daysToHoursCj, 0, 0, 0};
                double[] dayToHoursJD = new double[]{daysToHoursJudgeCj1, 0, 0, 0};
                if (daysToHoursJudgeCj <= C1.getTotalHoursInMonth() && daysToHoursJudgeCj1 <= C1.getTotalHoursInMonth() && pumpJH.getFlow()<150) {
                    //获取在本月时间段范围内，今天至本月底需要的小时
                    localMonthHours = getLocalMonthHours(C1, localMonthHours, nextMonth);

                    pumpHZ.setThisMonthWater(pumpHZ.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("洪泽"));
                    pumpJH.setThisMonthWater(pumpJH.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("金湖"));
                    pumpBY.setThisMonthWater(pumpBY.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("宝应"));
                    pumpJD.setThisMonthWater(pumpJD.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("江都"));

                    System.out.println("(2)抽江时，入江水道不足,加江都");
                    System.out.println(pumpHZ);
                    System.out.println(pumpJH);
                    System.out.println(pumpBY);
                    System.out.println("运行时间：");
                    //输出泵站运行时间范围
                    rjsdTimeRange = pumpTimePrint(C1, dayToHoursCj);
                    for (Time result : rjsdTimeRange) {
                        System.out.print("开始时间: " + result.getStartTime().format(formatter1) + "，");
                        System.out.println("结束时间: " + result.getEndTime().format(formatter1));
                    }
                    System.out.println(pumpJD);
                    System.out.println("运行时间：");
                    jdPumpTimeRange = pumpTimePrint(C1, dayToHoursJD);
                    for (Time result : jdPumpTimeRange) {
                        System.out.print("开始时间: " + result.getStartTime().format(formatter1) + "，");
                        System.out.println("结束时间: " + result.getEndTime().format(formatter1));
                    }
                    rjsdFinishTime = rjsdTimeRange.get(rjsdTimeRange.size() - 1).getEndTime().format(formatter1);
                    System.out.println("至" + rjsdFinishTime +"完成抽江" + decimalFormat.format(planWaterOutCJ/10000) +"亿m³");
                }
                else {

                    //如果是入江水道+江都不足，+里运河线
                    if (pumpJdDayChange){
                        pumpJD.setDay(pumpJdDay);
                        pumpJD.setFlow(pumpJD.getSumWater() / pumpJD.getDay() / 8.64);
                    }
                    if (pumpJD.getFlow() < 10.2){
                        pumpJD.setFlow(jdInitFlow);
                        pumpJD.setSumWater(planWaterOutCJ - pumpBY.getSumWater());
                        pumpJD.setDay(pumpJD.getSumWater() / pumpJD.getFlow() / 8.64);
                        if (pumpJD.getDay()*24 > C1.getTotalHoursInMonth()){
                            pumpJD.setFlow(pumpJH.getMaxFlow() / p.getRjsdProportion()[0] - pumpBY.getFlow());;
                            pumpJD.setDay(pumpBY.getDay());
                            pumpJD.setSumWater(pumpJD.getFlow() * pumpJD.getDay()*8.64);
                        }
                    }
                    else if (pumpJD.getFlow() > pumpJD.getMaxFlow()) {
                        pumpJD.setFlow(pumpJD.getMaxFlow());
                        pumpJD.setDay(pumpJD.getSumWater() / pumpJD.getFlow() / 8.64);
                    }
                    double cjWaterWest = pumpBY.getSumWater()+((pumpJH.getMaxFlow()/p.getRjsdProportion()[0]-pumpBY.getFlow())*pumpBY.getDay()*8.64);
                    //金湖站流量、水量、天数计算
                    pumpJH.setSumWater(cjWaterWest *p.getRjsdProportion()[0]);
                    pumpJH.setDay(pumpBY.getDay());
                    pumpJH.setFlow(pumpJH.getSumWater() / pumpJH.getDay()/8.64);
                    //洪泽站流量、水量、天数计算
                    pumpHZ.setSumWater(pumpJH.getSumWater() * p.getRjsdProportion()[1]);
                    pumpHZ.setDay(pumpBY.getDay());
                    pumpHZ.setFlow(pumpHZ.getSumWater() / pumpHZ.getDay()/8.64);

                    //淮安四站水量、流量设置、天数计算
                    pumpHA4.setSumWater(planWaterOutCJ * p.getRjsdProportion()[0] - pumpJH.getSumWater());
                    pumpHA4.setDay(pumpHZ.getDay());
                    pumpHA4.setFlow(pumpHA4.getSumWater()/pumpHA4.getDay()/8.64);
                    if (pumpHa4DayChange){
                        pumpHA4.setDay(pumpHa4Day);
                        pumpHA4.setFlow(pumpHA4.getSumWater() / pumpHA4.getDay() / 8.64);
                    }
                    if (pumpHA4.getFlow() < 33.4){
                        pumpHA4.setFlow(ha4InitFlow);
                        pumpHA4.setDay(pumpHA4.getSumWater() / pumpHA4.getFlow() / 8.64);
                    }
                    else if (pumpHA4.getFlow() > pumpHA4.getMaxFlow()) {
                        pumpHA4.setFlow(pumpHA4.getMaxFlow());
                        pumpHA4.setDay(pumpHA4.getSumWater() / pumpHA4.getFlow() / 8.64);
                    }
                    //淮阴三站水量、流量、天数计算
                    pumpHY3.setSumWater(pumpHA4.getSumWater() * p.getRjsdProportion()[1]);
                    pumpHY3.setDay(pumpHA4.getDay());
                    pumpHY3.setFlow(pumpHY3.getSumWater() / pumpHY3.getDay() / 8.64);
                    dayLyh = pumpHY3.getDay();
                    double daysToHoursJudgeCj2 = dayLyh * 24;
                    dayToHoursCj = new double[]{daysToHoursCj, 0, 0, 0};
                    dayJdPump = pumpJD.getDay();
                    daysToHoursJudgeCj1 = dayJdPump * 24;
                    dayToHoursJD = new double[]{daysToHoursJudgeCj1, 0, 0, 0};
                    double[] dayToHoursCj2 = new double[]{daysToHoursJudgeCj2, 0, 0, 0};
                    if (daysToHoursJudgeCj2 <= C1.getTotalHoursInMonth()) {

                        //获取在本月时间段范围内，今天至本月底需要的小时
                        localMonthHours = getLocalMonthHours(C1, localMonthHours, nextMonth);

                        pumpHZ.setThisMonthWater(pumpHZ.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("洪泽"));
                        pumpJH.setThisMonthWater(pumpJH.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("金湖"));
                        pumpBY.setThisMonthWater(pumpBY.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("宝应"));
                        pumpJD.setThisMonthWater(pumpJD.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("江都"));
                        pumpHA4.setThisMonthWater(pumpHA4.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("淮安4"));
                        pumpHY3.setThisMonthWater(pumpHY3.getFlow() * localMonthHours / 24 * 8.64 + lastMonthWaterMap.get("淮阴3"));

                        System.out.println("(3)抽江时，+江都,入江水道不足，+里运河");
                        System.out.println(pumpHZ);
                        System.out.println(pumpJH);
                        System.out.println(pumpBY);
                        rjsdTimeRange = pumpTimePrint(C1, dayToHoursCj);
                        for (Time result : rjsdTimeRange) {
                            System.out.print("开始时间: " + result.getStartTime().format(formatter1) + "，");
                            System.out.println("结束时间: " + result.getEndTime().format(formatter1));
                        }

                        System.out.println(pumpJD);
                        System.out.println("运行时间：");
                        //输出泵站运行时间范围
                        jdPumpTimeRange = pumpTimePrint(C1, dayToHoursJD);
                        for (Time result : jdPumpTimeRange) {
                            System.out.print("开始时间: " + result.getStartTime().format(formatter1) + "，");
                            System.out.println("结束时间: " + result.getEndTime().format(formatter1));
                        }

                        System.out.println(pumpHA4);
                        System.out.println(pumpHY3);
                        System.out.println("运行时间：");
                        //输出泵站运行时间范围
                        lyLakeTimeRange = pumpTimePrint(C1, dayToHoursCj2);
                        for (Time result : lyLakeTimeRange) {
                            System.out.print("开始时间: " + result.getStartTime().format(formatter1) + "，");
                            System.out.println("结束时间: " + result.getEndTime().format(formatter1));
                        }
                        rjsdFinishTime = rjsdTimeRange.get(rjsdTimeRange.size() - 1).getEndTime().format(formatter1);
                        System.out.println("至" + rjsdFinishTime +"完成抽江" + decimalFormat.format(planWaterOutCJ/10000) +"亿m³");

                    }
                }
            }
        }

        if (blLakeCondition) {
            System.out.println("——————计算台儿庄和不牢河出省——————");
            //蔺家坝水量、流量设置、天数计算
            pumpLJB.setFlow(ljbInitFlow);
            pumpLJB.setSumWater(ljbInitSumWater * 10000);
            pumpLJB.setDay(pumpLJB.getSumWater() / pumpLJB.getFlow() / 8.64);
            //解台站流量、水量、天数计算
            pumpXT.setFlow(pumpLJB.getFlow() * p.getBlLakeProportion1()[0]);
            pumpXT.setSumWater(pumpLJB.getSumWater() * p.getBlLakeProportion1()[0]);
            pumpXT.setDay(pumpXT.getSumWater() / pumpXT.getFlow() / 8.64);
            //刘山站流量、水量、天数计算
            pumpLS.setFlow(pumpXT.getFlow() * p.getBlLakeProportion1()[1]);
            pumpLS.setSumWater(pumpXT.getSumWater() * p.getBlLakeProportion1()[1]);
            pumpLS.setDay(pumpLS.getSumWater() / pumpLS.getFlow() / 8.64);
            System.out.println(pumpLJB);
            System.out.println(pumpXT);
            System.out.println(pumpLS);
            //台儿庄出省
            pumpTEZ.setFlow(tezInitFlow);
            pumpTEZ.setSumWater(planWaterToSD * 10000 - pumpLJB.getSumWater());
            pumpTEZ.setDay(pumpTEZ.getSumWater() / pumpTEZ.getFlow() / 8.64);
            System.out.println(pumpTEZ);
        }

        Map rulData = new HashMap();

        rulData.put("planWaterToSD",planWaterToSD);//下月计划调水出省
        rulData.put("nextMonth",nextMonth);//计划开始时间
        rulData.put("planWaterLmhNeed",planWaterLmhNeed);//需入骆马湖
        rulData.put("planWaterLMHneed",planWaterLMH/10000);//仍然入骆马湖水量
        rulData.put("planWaterOutCJ",planWaterOutCJ/10000);//抽江水量
        rulData.put("xhLakeTimeRange",xhLakeTimeRange);//徐洪河运行时间
        rulData.put("zyLakeTimeRange",zyLakeTimeRange);//中运河运行时间
        rulData.put("jdPumpTimeRange",jdPumpTimeRange);//江都站运行时间
        rulData.put("rjsdTimeRange",rjsdTimeRange);//入江水道运行时间
        rulData.put("lyLakeTimeRange",lyLakeTimeRange);//里运河运行时间
        rulData.put("xhLakeFinishTime",xhLakeFinishTime);//徐洪河结束时间
        rulData.put("xhLakeFinishTime1",xhLakeFinishTime1);//提前完成计划时间
        rulData.put("xhLakeFinishTime2",xhLakeFinishTime2);//双线输水运行满时间计划时间
        rulData.put("rjsdFinishTime",rjsdFinishTime);//入江水道结束时间
        List<pump> mapList = new ArrayList<>();
        mapList.add(pumpPZ);
        mapList.add(pumpSJ);
        mapList.add(pumpSN2);
        mapList.add(pumpSH);
        mapList.add(pumpHZ);
        mapList.add(pumpJH);
        mapList.add(pumpBY);
        mapList.add(pumpJD);
        mapList.add(pumpZH2);
        mapList.add(pumpLLJ2);
        mapList.add(pumpSY);
        mapList.add(pumpHA4);
        mapList.add(pumpHY3);
        mapList.add(pumpLJB);
        mapList.add(pumpXT);
        mapList.add(pumpTEZ);
        mapList.add(pumpLS);
        rulData.put("tableData",mapList);
        return rulData;

    }

    public static void main(String[] args) {
       List<TimeRangeData> paramDataList = new ArrayList<>();
        TimeRangeData paramData = new TimeRangeData();
        paramData.setSyear(2024);paramData.setSmonth(11);paramData.setSday(25);paramData.setShour(10);paramData.setSmin(0);
        paramData.setEyear(2024);paramData.setEmonth(12);paramData.setEday(1);paramData.setEhour(0);paramData.setEmin(0);
        paramDataList.add(paramData);
        TimeRangeData paramData9 = new TimeRangeData();
        paramData9.setSyear(2025);paramData9.setSmonth(12);paramData9.setSday(1);paramData9.setShour(0);paramData9.setSmin(0);
        paramData9.setEyear(2025);paramData9.setEmonth(12);paramData9.setEday(10);paramData9.setEhour(10);paramData9.setEmin(0);
        paramDataList.add(paramData9);
        TimeRangeData paramData1 = new TimeRangeData();
        paramData1.setSyear(2024);paramData1.setSmonth(12);paramData1.setSday(15);paramData1.setShour(10);paramData1.setSmin(0);
        paramData1.setEyear(2024);paramData1.setEmonth(12);paramData1.setEday(30);paramData1.setEhour(10);paramData1.setEmin(0);
        paramDataList.add(paramData1);
        TimeRangeData paramData2 = new TimeRangeData();
        paramData2.setSyear(2025);paramData2.setSmonth(1);paramData2.setSday(4);paramData2.setShour(10);paramData2.setSmin(0);
        paramData2.setEyear(2025);paramData2.setEmonth(1);paramData2.setEday(19);paramData2.setEhour(10);paramData2.setEmin(0);
        paramDataList.add(paramData2);
        TimeRangeData paramData3 = new TimeRangeData();
        paramData3.setSyear(2025);paramData3.setSmonth(2);paramData3.setSday(13);paramData3.setShour(10);paramData3.setSmin(0);
        paramData3.setEyear(2025);paramData3.setEmonth(2);paramData3.setEday(28);paramData3.setEhour(0);paramData3.setEmin(0);
        paramDataList.add(paramData3);
        TimeRangeData paramData4 = new TimeRangeData();
        paramData4.setSyear(2025);paramData4.setSmonth(3);paramData4.setSday(5);paramData4.setShour(10);paramData4.setSmin(0);
        paramData4.setEyear(2025);paramData4.setEmonth(3);paramData4.setEday(20);paramData4.setEhour(10);paramData4.setEmin(0);
        paramDataList.add(paramData4);
        TimeRangeData paramData5 = new TimeRangeData();
        paramData5.setSyear(2025);paramData5.setSmonth(3);paramData5.setSday(25);paramData5.setShour(10);paramData5.setSmin(0);
        paramData5.setEyear(2025);paramData5.setEmonth(4);paramData5.setEday(9);paramData5.setEhour(10);paramData5.setEmin(0);
        paramDataList.add(paramData5);
        TimeRangeData paramData6 = new TimeRangeData();
        paramData6.setSyear(2025);paramData6.setSmonth(4);paramData6.setSday(14);paramData6.setShour(10);paramData6.setSmin(0);
        paramData6.setEyear(2025);paramData6.setEmonth(4);paramData6.setEday(29);paramData6.setEhour(10);paramData6.setEmin(0);
        paramDataList.add(paramData6);
        TimeRangeData paramData7 = new TimeRangeData();
        paramData7.setSyear(2025);paramData7.setSmonth(5);paramData7.setSday(4);paramData7.setShour(10);paramData7.setSmin(0);
        paramData7.setEyear(2025);paramData7.setEmonth(5);paramData7.setEday(19);paramData7.setEhour(10);paramData7.setEmin(0);
        paramDataList.add(paramData7);
        TimeRangeData paramData8 = new TimeRangeData();
        paramData8.setSyear(2025);paramData8.setSmonth(5);paramData8.setSday(24);paramData8.setShour(10);paramData8.setSmin(0);
        paramData8.setEyear(2025);paramData8.setEmonth(5);paramData8.setEday(29);paramData8.setEhour(10);paramData8.setEmin(0);
        paramDataList.add(paramData8);

        Map<String,Object> map = new HashMap<>();
        map.put("timeRanges1",paramDataList);//抽江


        List<TimeRangeData> paramDataList1 = new ArrayList<>();
        TimeRangeData paramData10 = new TimeRangeData();
        paramData10.setSyear(2024);paramData10.setSmonth(11);paramData10.setSday(25);paramData10.setShour(10);paramData10.setSmin(0);
        paramData10.setEyear(2024);paramData10.setEmonth(12);paramData10.setEday(1);paramData10.setEhour(0);paramData10.setEmin(0);
        paramDataList1.add(paramData10);
        TimeRangeData paramData19 = new TimeRangeData();
        paramData19.setSyear(2024);paramData19.setSmonth(12);paramData19.setSday(1);paramData19.setShour(0);paramData19.setSmin(0);
        paramData19.setEyear(2024);paramData19.setEmonth(12);paramData19.setEday(10);paramData19.setEhour(10);paramData19.setEmin(0);
        paramDataList1.add(paramData19);
        TimeRangeData paramData11 = new TimeRangeData();
        paramData11.setSyear(2024);paramData11.setSmonth(12);paramData11.setSday(15);paramData11.setShour(10);paramData11.setSmin(0);
        paramData11.setEyear(2024);paramData11.setEmonth(12);paramData11.setEday(30);paramData11.setEhour(10);paramData11.setEmin(0);
        paramDataList1.add(paramData11);
        TimeRangeData paramData12 = new TimeRangeData();
        paramData12.setSyear(2025);paramData12.setSmonth(1);paramData12.setSday(4);paramData12.setShour(10);paramData12.setSmin(0);
        paramData12.setEyear(2025);paramData12.setEmonth(1);paramData12.setEday(19);paramData12.setEhour(10);paramData12.setEmin(0);
        paramDataList1.add(paramData12);
        TimeRangeData paramData13 = new TimeRangeData();
        paramData13.setSyear(2025);paramData13.setSmonth(2);paramData13.setSday(13);paramData13.setShour(10);paramData13.setSmin(0);
        paramData13.setEyear(2025);paramData13.setEmonth(2);paramData13.setEday(28);paramData13.setEhour(0);paramData13.setEmin(0);
        paramDataList1.add(paramData13);
        TimeRangeData paramData14 = new TimeRangeData();
        paramData14.setSyear(2025);paramData14.setSmonth(3);paramData14.setSday(5);paramData14.setShour(10);paramData14.setSmin(0);
        paramData14.setEyear(2025);paramData14.setEmonth(3);paramData14.setEday(20);paramData14.setEhour(10);paramData14.setEmin(0);
        paramDataList1.add(paramData14);
        TimeRangeData paramData15 = new TimeRangeData();
        paramData15.setSyear(2025);paramData15.setSmonth(3);paramData15.setSday(25);paramData15.setShour(10);paramData15.setSmin(0);
        paramData15.setEyear(2025);paramData15.setEmonth(4);paramData15.setEday(9);paramData15.setEhour(10);paramData15.setEmin(0);
        paramDataList1.add(paramData15);
        TimeRangeData paramData16 = new TimeRangeData();
        paramData16.setSyear(2025);paramData16.setSmonth(4);paramData16.setSday(14);paramData16.setShour(10);paramData16.setSmin(0);
        paramData16.setEyear(2025);paramData16.setEmonth(4);paramData16.setEday(29);paramData16.setEhour(10);paramData16.setEmin(0);
        paramDataList1.add(paramData16);

        TimeRangeData paramData17 = new TimeRangeData();
        paramData17.setSyear(2025);paramData17.setSmonth(5);paramData17.setSday(4);paramData17.setShour(10);paramData17.setSmin(0);
        paramData17.setEyear(2025);paramData17.setEmonth(5);paramData17.setEday(19);paramData17.setEhour(10);paramData17.setEmin(0);
        paramDataList1.add(paramData17);
        TimeRangeData paramData18 = new TimeRangeData();
        paramData18.setSyear(2025);paramData18.setSmonth(5);paramData18.setSday(24);paramData18.setShour(10);paramData18.setSmin(0);
        paramData18.setEyear(2025);paramData18.setEmonth(5);paramData18.setEday(29);paramData18.setEhour(10);paramData18.setEmin(0);
        paramDataList1.add(paramData18);

        map.put("timeRanges",paramDataList1);//供水

        plan p = new plan();
        double[] yearPlanWater = {10.01, 10.34, 11.53};//[调水出省：年入骆马湖：年抽江水量]
        p.setYearPlanWater(yearPlanWater);
        //徐洪河段损失比例计算
        double[] pumpXhhWater = {103400, 106972, 110038};//邳州站、沙集+睢宁二、泗洪站年计划提取水量
        p.setPumpXhhWater(pumpXhhWater);
        //入江水道计算损失比例计算
        double[] pumpRJSDWater = {115300, 115033, 113744};//宝应站、金湖站、洪泽站年计划提取水量
        p.setPumpRJSDWater(pumpRJSDWater);
        //中运河段 损失比例计算
        double[] pumpZyLakeWater = {56760, 57825, 58741};//皂河二、刘老涧二、泗阳站
        p.setPumpZyLakeWater(pumpZyLakeWater);
        //不牢河段 损失比例计算
        double[] pumpBlLakeWater2 = {5028, 5390, 5403};//蔺家坝、解台、刘山
        p.setPumpBlLakeWater2(pumpBlLakeWater2);
        map.put("year",p.getYearPlanWater());//年比例
        map.put("xhh",p.getPumpXhhWater());//徐洪河比例
        map.put("rjsd",p.getPumpRJSDWater());//入江水道比例
        map.put("zyh",p.getPumpZyLakeWater());//中运河比例
        map.put("blh",p.getPumpBlLakeWater2());//不牢河比例

        InPut lastMonthWater = new InPut();
        lastMonthWater.setSh(0);
        lastMonthWater.setSn2(0);
        lastMonthWater.setSj(0);
        lastMonthWater.setPz(0);
        lastMonthWater.setSy(0);
        lastMonthWater.setLlj2(0);
        lastMonthWater.setZh2(0);
        lastMonthWater.setHz(0);
        lastMonthWater.setJh(0);
        lastMonthWater.setJd(0);
        lastMonthWater.setBy(0);
        lastMonthWater.setHa4(0);
        lastMonthWater.setHy3(0);
        map.put("lastMonthWater",lastMonthWater);//日报水量


        System.out.println(rData(map));



            }


}

